<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
<head>
    <meta charset="utf-8">
    <title>添加类型</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/public.css" media="all">
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-container">
    <div class="col-md-4 column"  >
        <a class="btn btn-primary"  href="${pageContext.request.contextPath}/typeIndex">返回</a>
    </div>
    <div class="admin-login-background">
        <div class="layui-form login-form">
            <form class="layui-form" action="${pageContext.request.contextPath}/login/addTypeInfo" method="POST">
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username">ID</label>
                    <input type="text" name="id" placeholder="ID" autocomplete="off"
                           class="layui-input" >
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-username">图书类型</label>
                    <select name="typeName">
                        <option value="">请选择图书类型</option>
                        <option value="文学类">文学类</option>
                        <option value="历史类">历史类</option>
                        <option value="工学类">工学类</option>
                        <option value="法学类">法学类</option>
                        <option value="经济学类">经济学类</option>
                        <option value="统计学类">统计学类</option>
                    </select>
                </div>
                <div class="layui-form-item">
                    <label class="layui-icon layui-icon-password">备注</label>
                    <input type="text" name="remarks" placeholder="备注" autocomplete="off"
                           class="layui-input" >
                </div>
                <div class="layui-form-item">
                    <button type="submit" class="layui-btn layui-btn layui-btn-normal layui-btn-fluid" lay-submit=" "
                            lay-filter="login">添加
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="${pageContext.request.contextPath}/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;
        form.on('submit(login)', function (data) {
            console.log(data.field)
            var typeName = data.field.typeName;
            var id = data.field.id;
            if (typeName === '') {
                layer.msg('类型名不能为空');
                return false;
            }
            if (id === "") {
                layer.msg('id不能为空');
                return false;
            }
        });
    });
</script>
</body>
</html>